package org.rohmh.category.service;

import java.util.List;


import org.rohmh.category.domain.RohmhCategory;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PreFilter;
import org.springframework.transaction.annotation.Transactional;

@PreAuthorize("hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')")
public interface RohmhCategoryService {

    @PostFilter("filterObject.email == principal.username or hasRole('ROLE_ADMIN')")
    List<RohmhCategory> findAll();

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    List<RohmhCategory> findByLastName(String lastName);

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @Transactional
    void persist(RohmhCategory entity);

    @PreFilter("filterObject.email == principal.username")
    @Transactional
    void merge(RohmhCategory entity);

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @Transactional
    void remove(RohmhCategory entity);

    RohmhCategory find(Long id);
}
